var WxParse = require('../../wxParse/html2json.js');
const app = getApp()
Page({
  data: {
    curOneIndex: "c8afc08feb8142e49e2202ce55125956",
    curtwoIndex: 0
  },
  onLoad: function() {
     
    var that = this
    wx.getStorage({
      key: 'openid',
      success: function(res) {
        let openid = res.data
        wx.showLoading({
          title: '加载中',
        })
        wx.request({
          url: app.globalData.URL + '/app/product/proClassify?openid=' + openid,
          success: function (res) {
            wx.hideLoading()
            console.log(res)
            that.parseImg(res.data.list || [], that)
            that.setData({
              list: res.data.list || [],
              curOneIndex: res.data.list && res.data.list[0].id,
              paseImgObj: that.parseImg(res.data.list, that)
            })
          }
        })
      },
    })
    
  },
  parseImg:function(data,that){
    var parseImgObj = {}
    for (var i = 0; i < data.length; i++) {
      var itemTwo = data[i].childCode
      for (var j = 0; j < itemTwo.length; j++) {
        parseImgObj[itemTwo[j].id] = WxParse.html2json(itemTwo[j]['url'], 'returnData');
      }
    }

    return parseImgObj
  },
  //事件处理函数  
  switchRightTab: function(e) {
    // 获取item项的id，和数组的下标值  
    let id = e.target.dataset.id
    this.setData({
      curOneIndex: id
    })
  }

})